package com.version1_3.model;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

import java.util.*;

/**
 * Created by kuibu on 15/12/25.
 */
public class UserModel implements JsonSerializable {
    private int userId;
    private String UUID;
    private String tokenRY;
    private String userName;
    private String userPasswd;
    private String userPhoto;
    private String userSex;
    private String userTel;
    private int userCollectNum; // 需要计算
    private String userCollect; // 需要计算
    private JSONArray userFocusTypeIds;
    private String school;
    private int schoolYear;

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    private int height;
    private double weight;

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }



    public int getUserCollectNum() {
        return userCollectNum;
    }

    public void setUserCollectNum(int userCollectNum) {
        this.userCollectNum = userCollectNum;
    }

    public JSONArray getUserFocusTypeIds() {
        return userFocusTypeIds;
    }

    public void setUserFocusTypeIds(JSONArray userFocusTypeIds) {
        this.userFocusTypeIds = userFocusTypeIds;
    }

    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    public String getUUID() {
        return UUID;
    }

    public void setUUID(String UUID) {
        this.UUID = UUID;
    }

    public String getTokenRY() {
        return tokenRY;
    }

    public void setTokenRY(String tokenRY) {
        this.tokenRY = tokenRY;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPasswd() {
        return userPasswd;
    }

    public void setUserPasswd(String userPasswd) {
        this.userPasswd = userPasswd;
    }

    public String getUserPhoto() {
        return userPhoto;
    }

    public void setUserPhoto(String userPhoto) {
        this.userPhoto = userPhoto;
    }

    public String getUserSex() {
        return userSex;
    }

    public void setUserSex(String userSex) {
        this.userSex = userSex;
    }

    public String getUserTel() {
        return userTel;
    }

    public void setUserTel(String userTel) {
        this.userTel = userTel;
    }

    public int getUserCollectedNum() {
        return userCollectNum;
    }

    public void setUserCollectedNum(int userCollectNum) {
        this.userCollectNum = userCollectNum;
    }

    public String getUserCollect() {
        return userCollect;
    }

    public void setUserCollect(String userCollect) {
        this.userCollect = userCollect;
    }

    public String getSchool() {
        return school;
    }

    public void setSchool(String school) {
        this.school = school;
    }

    public int getSchoolYear() {
        return schoolYear;
    }

    public void setSchoolYear(int schoolYear) {
        this.schoolYear = schoolYear;
    }

    public UserModel() {
        this.userId = -1;
        this.UUID = "";
        this.tokenRY = "";
        this.userName = "";
        this.userPasswd = "";
        this.userPhoto = "";
        this.userSex = "";
        this.userTel = "";
        this.userCollectNum = 0;
        this.userCollect = "";
        this.userFocusTypeIds = null;
        this.school = "";
        this.schoolYear = 2012;
    }

    public UserModel(int userId, String tokenRY, String userName, int userCollectNum, String userPhoto, String userSex, String school, int schoolYear, JSONArray userFocusTypeIds) {
        this.userId = userId;
        this.tokenRY = tokenRY;
        this.userName = userName;
        this.userPhoto = userPhoto;
        this.userSex = userSex;
        this.userCollectNum = userCollectNum;
        this.userCollect = "";
        this.userFocusTypeIds = userFocusTypeIds;
        this.school = school;
        this.schoolYear = schoolYear;
    }

    @Override
    public String jsonSerialize() {
        Map<String, Object> userMap = new HashMap<>();
        userMap.put("userId", userId);
        userMap.put("userName", userName);
        userMap.put("userPhoto", userPhoto);
        userMap.put("userSex", userSex);
        userMap.put("userCollectedNum", userCollectNum);
        userMap.put("userCollect", userCollect);
        userMap.put("token", tokenRY);
        userMap.put("school", school);
        userMap.put("schoolYear", schoolYear);
        userMap.put("userFocusId", userFocusTypeIds);
        userMap.put("height", height);
        userMap.put("weight", weight);

        return JSON.toJSONString(userMap);
    }

    public Map<String,Object> mapSerialize() {
        Map<String, Object> userMap = new HashMap<>();
        userMap.put("userId", userId);
        userMap.put("userName", userName);
        userMap.put("userPhoto", userPhoto);
        userMap.put("userSex", userSex);
        userMap.put("userCollectedNum", userCollectNum);
        userMap.put("userCollect", userCollect);
        userMap.put("token", tokenRY);
        userMap.put("school", school);
        userMap.put("schoolYear", schoolYear);
        userMap.put("userFocusId", userFocusTypeIds);
        userMap.put("height", height);
        userMap.put("weight", weight);

        return userMap;
    }
}
